package com.haha.qqchannelbot.controller;

import java.io.IOException;


public class TestController {

    public static void main(String[] args) throws IOException {

        String text = """
            create table file_data_%s partition of file_data_all
            (primary key (file_id))
         for values from ('20%s-%s-01 00:00:00') to ('20%s-%s-01 00:00:00');
        
         create unique index file_data_%s_file_id_idx on file_data_%s (file_id);
        
        create index file_data_%s_index
            on file_data_%s (file_name, file_type, file_size, http_url, create_time, sys_code);
                """;

        Integer year = 24;
        Integer quarter = 1;
        Integer month = 01;

        for (int i = year; i <= 35; i++) {
            for (int j = quarter; j <= 4; j++) {
                int month1 = j * 3 - 2;
                int month2 = j * 3 + 1;
                String tableName = i + "0" + j;
                int i1 = month2 > 12 ? month2 - 12 : month2;
                System.out.println(String.format(text, tableName, i, String.valueOf(month1).length() == 1 ? "0"+month1 : month1, (month2 > 12 ? i + 1 : i),
                        String.valueOf(i1).length() == 1 ? "0"+ i1 : i1, tableName, tableName, tableName, tableName));
            }
        }

    }



}
